package com.xmy.solution.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xmy.common.annotation.Log;
import com.xmy.common.core.controller.BaseController;
import com.xmy.common.core.domain.AjaxResult;
import com.xmy.common.enums.BusinessType;
import com.xmy.solution.domain.Contacts;
import com.xmy.solution.service.IContactsService;
import com.xmy.common.utils.poi.ExcelUtil;
import com.xmy.common.core.page.TableDataInfo;

/**
 * 客服管理Controller
 * 
 * @author 夏明毅
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/solution/contacts")
public class ContactsController extends BaseController
{
    @Autowired
    private IContactsService contactsService;

    /**
     * 查询客服管理列表
     */
    @PreAuthorize("@ss.hasPermi('solution:contacts:list')")
    @GetMapping("/list")
    public TableDataInfo list(Contacts contacts)
    {
        startPage();
        List<Contacts> list = contactsService.selectContactsList(contacts);
        return getDataTable(list);
    }
    @GetMapping("/AppList")
    public TableDataInfo AppList(Contacts contacts)
    {
        startPage();
        List<Contacts> list = contactsService.selectContactsList(contacts);
        return getDataTable(list);
    }

    /**
     * 导出客服管理列表
     */
    @PreAuthorize("@ss.hasPermi('solution:contacts:export')")
    @Log(title = "客服管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Contacts contacts)
    {
        List<Contacts> list = contactsService.selectContactsList(contacts);
        ExcelUtil<Contacts> util = new ExcelUtil<Contacts>(Contacts.class);
        util.exportExcel(response, list, "客服管理数据");
    }

    /**
     * 获取客服管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('solution:contacts:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(contactsService.selectContactsById(id));
    }

    /**
     * 新增客服管理
     */
    @PreAuthorize("@ss.hasPermi('solution:contacts:add')")
    @Log(title = "客服管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Contacts contacts)
    {
        return toAjax(contactsService.insertContacts(contacts));
    }

    /**
     * 修改客服管理
     */
    @PreAuthorize("@ss.hasPermi('solution:contacts:edit')")
    @Log(title = "客服管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Contacts contacts)
    {
        return toAjax(contactsService.updateContacts(contacts));
    }

    /**
     * 删除客服管理
     */
    @PreAuthorize("@ss.hasPermi('solution:contacts:remove')")
    @Log(title = "客服管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(contactsService.deleteContactsByIds(ids));
    }
}
